package com.bustle.order.dto.account;

import javax.ejb.EJB;
import javax.ejb.Local;
import javax.ejb.Stateless;

import com.bustle.commons.MapConverter;
import com.bustle.order.data.Account;
import com.bustle.user.dto.user.UserToDtoMapConverter;

@Local
public interface AccountToDtoMapConverter extends MapConverter<Account, AccountDto>
{
  @Stateless
  public class DefaultAccountToDtoMapConverter extends AbstractMapConverter<Account, AccountDto> implements AccountToDtoMapConverter
  {
    @Override
    public void doMapping(Account aSource, AccountDto aDestination)
    {
      aDestination.setId(aSource.getIdAccount());
      aDestination.setUser(userToDtoMapConverter.map(aSource.getUser(), aDestination.getUser()));
      aDestination.setCreationDate(aSource.getCreationDate());
    }

    @Override
    protected AccountDto build()
    {
      return new AccountDto();
    }

    @EJB
    protected UserToDtoMapConverter userToDtoMapConverter;
  }
}
